<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  components: {
      SelectDataGoods: async () =>
          Vue.extend(await Vue.prototype.$vFN.Components.Base.SelectDataGoods()),
  },
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "plugin/team-dividend/admin/product/list",
        // delete: "plugin/team-dividend/admin/level/destroyLevel",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {},
   
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "收款帐户名",
            prop: "real_name",
          },
          {
            label: "申请提现金额",
            prop: "amount",
          },
        ],
      },
      // 表格数据类型
      mixinTable_tableDataType: "tree",
    };
  },
  methods: {
    async addProduct() {
      this.goodsIds = [];
      this.$vFN.Directives.SelectDataGoods({
          appWindow: this.appWindow,
          selectIds: this.goodsIds,
          count: 1,
          apiConfig:this.$vFN.Tools.getAppGlobalData("componentsApiConfig.SelectDataGoods",this.appWindow),
          onSuccess: (res) => {
            // console.error(res, "1243242414214");
            this.goodsIds = res;
            this.getProduct()
          },
      });
    },
    async getProduct() {
      let res = await this.$vFN.Http.post({
        url: "plugin/team-dividend/admin/product/insertion",
        data: {
            product_id: this.goodsIds[0],
        }
      },window)
      if(res.code == 200) {
        this.mixinTable_refreshData();
        this.$vFN.Tools.messageSuccess("操作成功");
      }
    },
    // 打开添加/修改
    async editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        id: params_.id,
        data: params_.data,
        onSuccess: () => {
          this.mixinTable_refreshData()
        }
      });
    },
    // 初始化
    async init() {
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>